package edu.cth.scrabbit.client.view.panels;

import java.awt.Color;

import javax.swing.GroupLayout;
import javax.swing.JComponent;
import javax.swing.JLabel;

import org.jdesktop.application.Application;

/**
 * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI
 * Builder, which is free for non-commercial use. If Jigloo is being used
 * commercially (ie, by a corporation, company or business for any purpose
 * whatever) then you should purchase a license for each developer using Jigloo.
 * Please visit www.cloudgarden.com for details. Use of Jigloo implies
 * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN
 * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR
 * ANY CORPORATE OR COMMERCIAL PURPOSE.
 */
public class PlayerPanel extends javax.swing.JPanel {
	private JLabel nameLabel;
	private JLabel pointsLabel;

	/**
	 * Auto-generated main method to display this JPanel inside a new JFrame.
	 */

	public PlayerPanel() {
		super();
		initGUI();
	}

	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent) this);
			this.setLayout(thisLayout);
			this.setPreferredSize(new java.awt.Dimension(162, 57));
			{
				nameLabel = new JLabel();

			}
			{
				pointsLabel = new JLabel();
			}
			thisLayout.setVerticalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addGroup(
							thisLayout
									.createParallelGroup(
											GroupLayout.Alignment.BASELINE)
									.addComponent(nameLabel,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE, 27,
											GroupLayout.PREFERRED_SIZE)
									.addComponent(pointsLabel,
											GroupLayout.Alignment.BASELINE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE,
											GroupLayout.PREFERRED_SIZE))
					.addContainerGap(18, 18));
			thisLayout.setHorizontalGroup(thisLayout
					.createSequentialGroup()
					.addContainerGap()
					.addComponent(nameLabel, GroupLayout.PREFERRED_SIZE, 71,
							GroupLayout.PREFERRED_SIZE).addGap(37)
					.addComponent(pointsLabel, 0, 30, Short.MAX_VALUE)
					.addContainerGap());
			Application.getInstance().getContext().getResourceMap(getClass())
					.injectComponents(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		this.setVisible(false);
	}

	public void setPlayerName(String name) {
		nameLabel.setText(name);
		this.setVisible(true);
	}

	public void setScore(int score) {
		pointsLabel.setText("" + score);
	}

	public void setBackgroundColor(boolean changeColor) {
		if (changeColor) {
			setBackground(Color.CYAN);
		} else {
			setBackground(Color.LIGHT_GRAY);
		}
	}
}
